package com.erp.pro.service.impl;

import com.erp.common.service.DictService;
import com.erp.oa.domain.NotifyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.erp.pro.dao.ProductDao;
import com.erp.pro.domain.ProductDO;
import com.erp.pro.service.ProductService;



@Service
public class ProductServiceImpl implements ProductService {
	@Autowired
	private ProductDao productDao;

	@Autowired
	private DictService dictService;

	@Override
	public ProductDO get(Long id){
		return productDao.get(id);
	}
	
	@Override
	public List<ProductDO> list(Map<String, Object> map){
		List<ProductDO> productDOList =  productDao.list(map);
		for (ProductDO productDO : productDOList) {
			productDO.setStatus(dictService.getName("pro_status", productDO.getStatus()));
		}
		return productDOList;
	}
	
	@Override
	public int count(Map<String, Object> map){
		return productDao.count(map);
	}
	
	@Override
	public int save(ProductDO product){
		return productDao.save(product);
	}
	
	@Override
	public int update(ProductDO product){
		return productDao.update(product);
	}
	
	@Override
	public int remove(Long id){
		return productDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return productDao.batchRemove(ids);
	}

	@Override
	public ProductDO getsku(Map<String, Object> params) {
		if(productDao.list(params).size()>0){
			return productDao.list(params).get(0);
		}else {
			return null;
		}

	}

	@Override
	public ProductDO getskuinfo(String sku) {
		return productDao.getskuinfo(sku);
	}

	@Override
	public int reduStock(Long skuid, Integer outQty) {
		return productDao.reduStock(skuid,outQty);
	}

	@Override
	public List<String> getProBrand() {
		return productDao.getProBrand();
	}

}
